float4x4 World;
float4x4 View;
float4x4 Projection;
float4 Color;
float Time;
float glow; 
uniform extern texture UserTexture; 

struct VS_OUTPUT
{
    float4 position  : POSITION;
    float2 textureCoordinate : TEXCOORD0;
};

sampler textureSampler = sampler_state
{
    Texture = <UserTexture>;
    mipfilter = LINEAR;  
    AddressU = Wrap;
    AddressV = Wrap;
}; 

struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 Texcoord : TEXCOORD0;
    float3 Normal : NORMAL0;

    // TODO: add input channels such as texture
    // coordinates and vertex colors here.
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float2 Texcoord : TEXCOORD0;

    // TODO: add vertex shader outputs such as colors and texture
    // coordinates here. These values will automatically be interpolated
    // over the triangle, and provided as input to your pixel shader.
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;
    float4 offset = 0.05 * float4(sin(Time +  World._41), sin(Time  + World._42), 0, 0);
    float4 worldPosition = mul(input.Position + offset, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	output.Texcoord = input.Texcoord;
	output.Texcoord.y = 1-output.Texcoord.y;
    // TODO: add your vertex shader code here.

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{     
float4 col = tex2D(textureSampler, input.Texcoord);
return col;
 
} 
float4 psglow(VertexShaderOutput input) : COLOR0
{     
float4 col = tex2D(textureSampler, input.Texcoord);
col.w *= pow( frac(glow), 2) + 0.25f;//( glsin( frac(glow * 1) * 3.14) * 0.25f + 0.75;
return col;
 
} 
technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    } 
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 psglow();
    } 
}
